import { RouteRecordPlus } from '@/router/type';

const IFrame = () => import('@/layouts/components/FrameBlank.vue');
const Layout = () => import('@/layouts/index.vue');

const routes: RouteRecordPlus[] = [];

// 通过环境配置可忽略生产环境启用
if (import.meta.env.VITE_ENABLED_ROUTE_DEV === 'true') {
  routes.push({
    path: '/develop',
    component: Layout,
    redirect: '/develop/tool',
    meta: { title: '开发', icon: 'setting', anon: true, sort: 9999 },
    children: [
      {
        path: 'tool',
        redirect: '/develop/tool/generator',
        meta: { title: '开发工具', icon: 'setting', anon: true },
        children: [
          {
            path: 'generator',
            component: () => import('@/pages/develop/tool/generator/Index.vue'),
            meta: { title: '代码生成', anon: true, shared: true, isAlive: true },
          },
          {
            path: 'init',
            component: () => import('@/pages/develop/tool/init/init.vue'),
            meta: { title: '系统初始化', anon: true, shared: true, isAlive: true },
          },
        ],
      },
      {
        path: 'demo',
        redirect: '/develop/demo/mock',
        meta: { title: 'demo', icon: 'setting', anon: true },
        children: [
          {
            path: 'mock',
            component: () => import('@/pages/develop/demo/mock/List.vue'),
            meta: { title: '组合页面', anon: true, shared: true },
          },
          {
            path: 'PageWrapper',
            component: () => import('@/pages/develop/demo/mock/Wrapper.vue'),
            meta: { title: '简单页面', anon: true, shared: true },
          },
          {
            path: 'crud',
            component: () => import('@/pages/develop/demo/crud/List.vue'),
            meta: { title: '增删改查', anon: true, shared: true },
          },
        ],
      },
      {
        path: 'component',
        redirect: '/develop/component/LgTable',
        meta: { title: '组件', icon: 'wallet', anon: true },
        children: [
          {
            path: 'LgTable',
            component: () => import('@/pages/develop/component/LgTableDoc.vue'),
            meta: { title: 'LgTable', anon: true },
          },
          {
            path: 'lgForm',
            component: () => import('@/pages/develop/component/LgFormDoc.vue'),
            meta: { title: 'LgForm', anon: true },
          },
          {
            path: 'LgDescription',
            component: () => import('@/pages/develop/component/LgDescriptionDoc.vue'),
            meta: { title: 'LgDescription', anon: true },
          },
          {
            path: 'LgSearchBar',
            component: () => import('@/pages/develop/component/LgSearchBarDoc.vue'),
            meta: { title: 'LgSearchBar', anon: true },
          },
          {
            path: 'LgDict',
            component: () => import('@/pages/develop/component/LgDictDoc.vue'),
            meta: { title: 'LgDict', anon: true },
          },
          {
            path: 'LgBizSelect',
            component: () => import('@/pages/develop/component/LgBizSelectDoc.vue'),
            meta: { title: 'LgBizSelect', anon: true },
          },
          {
            path: 'LgBizTree',
            component: () => import('@/pages/develop/component/LgBizTreeDoc.vue'),
            meta: { title: 'LgBizTree', anon: true },
          },
          {
            path: 'LgPicker',
            component: () => import('@/pages/develop/component/LgPickerDoc.vue'),
            meta: { title: 'LgPicker', anon: true },
          },
          // {
          //   path: 'LgBizTree',
          //   component: () => import('@/pages/develop/component/LgBizTreeDoc.vue'),
          //   meta: { title: 'LgBizTree', anon: true },
          // },
          {
            path: 'LgUpload',
            component: () => import('@/pages/develop/component/LgUploadDoc.vue'),
            meta: { title: 'LgUpload', anon: true },
          },
          {
            path: 'LgButtonList',
            component: () => import('@/pages/develop/component/LgButtonListDoc.vue'),
            meta: { title: 'LgButtonList', anon: true },
          },
          {
            path: 'LgGrid',
            component: () => import('@/pages/develop/component/LgGridDoc.vue'),
            meta: { title: 'LgGrid', anon: true },
          },
          {
            path: 'LgCountdown',
            component: () => import('@/pages/develop/component/LgCountdownDoc.vue'),
            meta: { title: 'LgCountdown', anon: true },
          },
          {
            path: 'LgFormat',
            name: 'lg-format-doc',
            component: () => import('@/pages/develop/component/LgFormatDoc.vue'),
            meta: { title: 'LgFormat', anon: true },
          },
          {
            path: 'LgAutoComplete',
            name: 'lg-auto-complete-doc',
            component: () => import('@/pages/develop/component/LgAutoCompleteDoc.vue'),
            meta: { title: 'LgAutoComplete', anon: true },
          },
          {
            path: 'LgCollapse',
            name: 'LgCollapseDoc',
            component: () => import('@/pages/develop/component/LgCollapseDoc.vue'),
            meta: { title: 'LgCollapse', anon: true },
          },
          {
            path: 'LgWangeditor',
            name: 'LgWangeditorDoc',
            component: () => import('@/pages/develop/component/LgWangeditorDoc.vue'),
            meta: { title: 'LgWangeditor', anon: true },
          },
        ],
      },
      {
        path: '/frame',
        name: 'Frame',
        component: Layout,
        redirect: '/frame/doc',
        meta: {
          icon: 'internet',
          title: '文档',
        },
        children: [
          {
            path: 'lg-soar',
            name: 'lg-soar',
            component: IFrame,
            meta: {
              frameSrc: `${
                import.meta.env.VITE_PROXY_SERVER || location.origin + import.meta.env.VITE_SERVER_BASE_URL
              }/doc.html`,
              frameBlank: true,
              title: '接口文档',
            },
          },
          {
            path: 'lg-soar',
            name: 'lg-soar',
            component: IFrame,
            meta: {
              frameSrc: 'https://gitee.com/lgx1992/lg-soar/wikis/pages',
              frameBlank: true,
              title: '开发文档',
            },
          },
          {
            path: 'TDesign2',
            name: 'TDesign2',
            component: IFrame,
            meta: {
              frameSrc: 'https://tdesign.tencent.com/vue-next/getting-started',
              frameBlank: true,
              title: 'UI组件文档',
            },
          },
        ],
      },
      {
        path: '/issues',
        name: 'issues',
        component: IFrame,
        meta: {
          icon: 'bug',
          frameSrc: 'https://gitee.com/lgx1992/lg-soar/issues',
          frameBlank: true,
          title: '我要提bug',
        },
      },
      {
        path: '/star',
        name: 'Star',
        component: IFrame,
        meta: {
          icon: 'star',
          frameSrc: 'https://gitee.com/lgx1992/lg-soar',
          frameBlank: true,
          title: '点个Star',
        },
      },
    ],
  });
}

export default routes;
